home *** CD-ROM | disk | FTP | other *** search
- program Dstart;
-
- {$R *.res}
-
- uses Classes, WinTypes, WinProcs, Messages, SysUtils;
- var
- SearchRec : TSearchRec;
- PopupMenu : HMenu;
- Msg : TMSG;
- ReturnValue: integer;
- ret : integer;
- cpos : TPOINT;
- iptr : PChar;
- buf : array [0..255] of char;
- noch : integer;
- flags : word;
- i,x,y : integer;
- hHookedWnd : HWND;
- tmpstr : string;
- startdir : string;
- curDCL : string;
- files : TStringList;
- dStartClass: array [0..255] of char;
-
- function NewMsgHandler(Window : HWnd; Message : Word;
- wParam : Word; lParam : LongInt) : LongInt; export;
- begin
-
- case Message of
- wm_Command : begin
- case WParam of
- 1..20: ReturnValue := WParam;
- end;
- end;
- end;
- end;
-
- function QuickWindow:HWND;
- var
- wc : TWNDCLASS;
-
- begin
- { Register the window class. }
- StrPCopy(dStartClass,'Delphi Start');
- wc.style := 0;
- wc.lpfnWndProc := @NewMsgHandler;
- wc.cbClsExtra := 0;
- wc.cbWndExtra := 0;
- wc.hInstance := hInstance;
- wc.hIcon := 0;
- wc.hCursor := LoadCursor(0,IDC_ARROW);
- wc.hbrBackground := 0;
- wc.lpszMenuName := nil;
-
- wc.lpszClassName := dStartClass;
-
- if RegisterClass(wc) then
- QuickWindow := CreateWindow(dStartClass, 'Delphi Start',
- WS_OVERLAPPED or WS_SYSMENU, CW_USEDEFAULT, 0,
- CW_USEDEFAULT, 0, 0, 0,
- hInstance, nil );
-
- end;
-
- begin
- getdir(0,StartDir); {record start dir, i.e. working directory of
- pm icon}
- ReturnValue := 0;
-
- GetCursorPos(cpos);
- x := cpos.x;
- y := cpos.y;
-
- hHookedWnd := QuickWindow; {create invisible window to receive messages}
-
- i:=0;
- flags := 0;
-
- {load current component library setting, and get directory part of it by
- setting
- last \ to 0}
- ret :=
- GetPrivateProfileString('Library','ComponentLibrary','',buf,225,'DELPHI.INI');
- iptr := StrRScan(buf,'\');
- iptr[0] := chr(0);
- tmpstr := StrPas(buf);
- iptr := iptr+1;
- curDCL := StrPas(iptr);
-
-
- files := TStringList.Create;
- PopupMenu := CreatePopupMenu;
- AppendMenu(PopupMenu,mf_disabled,0,buf);
-
- {Change directory to component library dir and list all files in the directory
- For each file, add to menu and a string list - the latter for use later if a
- menu item is chosen}
- chdir(tmpstr);
- ret := FindFirst('*.DCL',faAnyFile , SearchRec);
- while ret = 0 do begin
- StrPCopy(buf,SearchRec.Name);
- files.add(SearchRec.Name);
- i:= i + 1;
- if SearchRec.Name = curDCL then
- flags := mf_checked
- else
- flags := 0;
-
- AppendMenu(PopupMenu,flags,i,buf);
- ret := FindNext(SearchRec);
- end;
-
- {..and display the menu}
- TrackPopupMenu(PopupMenu,0,x,y,0,hHookedWnd,nil);
-
- {Check for whether a menu selection was made}
- if PeekMessage(Msg,hHookedWnd,0,32767,PM_REMOVE) then
- DispatchMessage(Msg);
-
- {get rid of window created by QuickWindow}
- DestroyWindow(hHookedWnd);
- UnregisterClass(dStartClass,hInstance);
-
- {only process anything if return value > 0 i.e. a menu item has been chosen}
- if ReturnValue > 0 then begin
- getdir(0,tmpstr);
- tmpstr := tmpstr + '\' + files[ReturnValue - 1];
- StrPCopy(buf,tmpstr);
- WritePrivateProfileString('Library','ComponentLibrary',buf,'DELPHI.INI');
- getdir(0,tmpstr);
- tmpstr := tmpstr + '\DELPHI.EXE ';
- StrPCopy(buf,tmpstr);
- StrCat(buf, cmdLine);
- chdir(StartDir);
- WinExec(buf,cmdShow);
- end;
-
-
- end.
-